import http from "@/api/index.ts";
import { store } from "@/redux";
const routers = "Song";
export const api = {
  // 获取菜单列表
  treeData: () => {
    return http.get<any>(
      `/api/system/Menu/SystemAndModule/treeData`,
      {},
      {
        headers: {
          Authorization: store.getState().user.token,
          loading: true
        },
        baseUrlKey: routers
      }
    );
  },

  // 获取所有子菜单
  commonModuleAll: (pId: string) => {
    return http.get<any>(
      `/api/system/Menu/CommonModuleAll/${pId}`,
      {},
      {
        headers: {
          Authorization: store.getState().user.token,
          loading: true
        },
        baseUrlKey: routers
      }
    );
  },

  // 获取常用菜单列表
  commonModule: (pId: string) => {
    return http.get<any>(
      `/api/system/Menu/CommonModule/${pId}`,
      {},
      {
        headers: {
          Authorization: store.getState().user.token,
          loading: true
        },
        baseUrlKey: routers
      }
    );
  },

  // 设为常用菜单
  addCommonModule: (params: any) => {
    return http.post<any>(`/api/system/CommonModule`, params, {
      headers: {
        Authorization: store.getState().user.token,
        loading: true
      },
      baseUrlKey: routers
    });
  },
  // 设为常用菜单
  delCommonModule: (params: any) => {
    return http.post<any>(`/api/system/CommonModule/undo`, params, {
      headers: {
        Authorization: store.getState().user.token,
        loading: true
      },
      baseUrlKey: routers
    });
  },

  // 退出登录
  logoutApi: () => {
    return http.get<any>(
      `/api/oauth/Logout`,
      {},
      {
        headers: {
          Authorization: store.getState().user.token,
          loading: true
        },
        baseUrlKey: routers
      }
    );
  }
};
